package interfaz;

import javax.swing.JPanel;

import java.awt.Color;

import javax.swing.border.TitledBorder;
import javax.swing.UIManager;

import java.awt.GridBagLayout;

import javax.swing.JLabel;

import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.event.ActionListener;

import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.JButton;

public class RegistroPanel extends JPanel implements IVista{
	private JTextField txtNombre;
	private JTextField txtDNI;
	private JTextField txtApellidos;
	private JTextField txtEmail;
	private JTextField txtTelefono;
	private JTextField txtDireccion;
	private JTextField txtProvincia;
	private JTextField txtCodPostal;
	private JTextField txtUsuario;
	private JPasswordField txtPass1;
	private JPasswordField txtPass2;
	private JButton btnAceptar;
	private JButton btnCancelar;

	/**
	 * Create the panel.
	 */
	public RegistroPanel() {
		setBackground(Color.WHITE);
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{15, 459, 15, 0};
		gridBagLayout.rowHeights = new int[]{39, 148, 0, 0, 0, 17, 0, 0, 0, 0, 0};
		gridBagLayout.columnWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		JPanel panelDatos = new JPanel();
		panelDatos.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Datos personales", TitledBorder.LEFT, TitledBorder.TOP, null, null));
		panelDatos.setBackground(Color.WHITE);
		GridBagConstraints gbc_panelDatos = new GridBagConstraints();
		gbc_panelDatos.insets = new Insets(0, 0, 5, 5);
		gbc_panelDatos.fill = GridBagConstraints.BOTH;
		gbc_panelDatos.gridx = 1;
		gbc_panelDatos.gridy = 1;
		add(panelDatos, gbc_panelDatos);
		GridBagLayout gbl_panelDatos = new GridBagLayout();
		gbl_panelDatos.columnWidths = new int[]{30, 73, 0, 0, 0, 0};
		gbl_panelDatos.rowHeights = new int[]{15, 0, 10, 0, 10, 0, 0, 0};
		gbl_panelDatos.columnWeights = new double[]{0.0, 0.0, 0.0, 1.0, 1.0, Double.MIN_VALUE};
		gbl_panelDatos.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		panelDatos.setLayout(gbl_panelDatos);
		
		JLabel lblNombre = new JLabel("Nombre");
		GridBagConstraints gbc_lblNombre = new GridBagConstraints();
		gbc_lblNombre.anchor = GridBagConstraints.WEST;
		gbc_lblNombre.insets = new Insets(0, 0, 5, 5);
		gbc_lblNombre.gridx = 1;
		gbc_lblNombre.gridy = 1;
		panelDatos.add(lblNombre, gbc_lblNombre);
		
		txtNombre = new JTextField();
		txtNombre.setColumns(10);
		GridBagConstraints gbc_txtNombre = new GridBagConstraints();
		gbc_txtNombre.fill = GridBagConstraints.BOTH;
		gbc_txtNombre.insets = new Insets(0, 0, 5, 5);
		gbc_txtNombre.gridx = 3;
		gbc_txtNombre.gridy = 1;
		panelDatos.add(txtNombre, gbc_txtNombre);
		
		JLabel lblApellidos = new JLabel("Apellidos");
		GridBagConstraints gbc_lblApellidos = new GridBagConstraints();
		gbc_lblApellidos.anchor = GridBagConstraints.WEST;
		gbc_lblApellidos.insets = new Insets(0, 0, 5, 5);
		gbc_lblApellidos.gridx = 1;
		gbc_lblApellidos.gridy = 3;
		panelDatos.add(lblApellidos, gbc_lblApellidos);
		
		txtApellidos = new JTextField();
		txtApellidos.setColumns(10);
		GridBagConstraints gbc_txtApellidos = new GridBagConstraints();
		gbc_txtApellidos.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtApellidos.insets = new Insets(0, 0, 5, 5);
		gbc_txtApellidos.gridx = 3;
		gbc_txtApellidos.gridy = 3;
		panelDatos.add(txtApellidos, gbc_txtApellidos);
		
		JLabel lblDNI = new JLabel("DNI/CIF");
		GridBagConstraints gbc_lblDNI = new GridBagConstraints();
		gbc_lblDNI.anchor = GridBagConstraints.WEST;
		gbc_lblDNI.insets = new Insets(0, 0, 5, 5);
		gbc_lblDNI.gridx = 1;
		gbc_lblDNI.gridy = 5;
		panelDatos.add(lblDNI, gbc_lblDNI);
		
		 txtDNI = new JTextField();
		txtDNI.setColumns(10);
		GridBagConstraints gbc_txtDNI = new GridBagConstraints();
		gbc_txtDNI.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtDNI.insets = new Insets(0, 0, 5, 5);
		gbc_txtDNI.gridx = 3;
		gbc_txtDNI.gridy = 5;
		panelDatos.add(txtDNI, gbc_txtDNI);
		
		JPanel paneContacto = new JPanel();
		paneContacto.setBorder(new TitledBorder(null, "Datos de contacto", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		paneContacto.setBackground(Color.WHITE);
		GridBagConstraints gbc_paneContacto = new GridBagConstraints();
		gbc_paneContacto.anchor = GridBagConstraints.NORTH;
		gbc_paneContacto.insets = new Insets(0, 0, 5, 5);
		gbc_paneContacto.fill = GridBagConstraints.HORIZONTAL;
		gbc_paneContacto.gridx = 1;
		gbc_paneContacto.gridy = 3;
		add(paneContacto, gbc_paneContacto);
		GridBagLayout gbl_paneContacto = new GridBagLayout();
		gbl_paneContacto.columnWidths = new int[]{30, 0, 0, 0, 0, 0};
		gbl_paneContacto.rowHeights = new int[]{15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 0, 0};
		gbl_paneContacto.columnWeights = new double[]{0.0, 0.0, 0.0, 1.0, 1.0, Double.MIN_VALUE};
		gbl_paneContacto.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		paneContacto.setLayout(gbl_paneContacto);
		
		JLabel label_3 = new JLabel("Email");
		GridBagConstraints gbc_label_3 = new GridBagConstraints();
		gbc_label_3.anchor = GridBagConstraints.WEST;
		gbc_label_3.insets = new Insets(0, 0, 5, 5);
		gbc_label_3.gridx = 1;
		gbc_label_3.gridy = 1;
		paneContacto.add(label_3, gbc_label_3);
		
		txtEmail = new JTextField();
		txtEmail.setColumns(10);
		GridBagConstraints gbc_txtEmail = new GridBagConstraints();
		gbc_txtEmail.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtEmail.insets = new Insets(0, 0, 5, 5);
		gbc_txtEmail.gridx = 3;
		gbc_txtEmail.gridy = 1;
		paneContacto.add(txtEmail, gbc_txtEmail);
		
		JLabel label_4 = new JLabel("Tel\u00E9fono");
		GridBagConstraints gbc_label_4 = new GridBagConstraints();
		gbc_label_4.anchor = GridBagConstraints.WEST;
		gbc_label_4.insets = new Insets(0, 0, 5, 5);
		gbc_label_4.gridx = 1;
		gbc_label_4.gridy = 3;
		paneContacto.add(label_4, gbc_label_4);
		
		txtTelefono = new JTextField();
		txtTelefono.setColumns(10);
		GridBagConstraints gbc_txtTelefono = new GridBagConstraints();
		gbc_txtTelefono.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtTelefono.anchor = GridBagConstraints.SOUTH;
		gbc_txtTelefono.insets = new Insets(0, 0, 5, 5);
		gbc_txtTelefono.gridx = 3;
		gbc_txtTelefono.gridy = 3;
		paneContacto.add(txtTelefono, gbc_txtTelefono);
		
		JLabel label_5 = new JLabel("Direcci\u00F3n");
		GridBagConstraints gbc_label_5 = new GridBagConstraints();
		gbc_label_5.anchor = GridBagConstraints.WEST;
		gbc_label_5.insets = new Insets(0, 0, 5, 5);
		gbc_label_5.gridx = 1;
		gbc_label_5.gridy = 5;
		paneContacto.add(label_5, gbc_label_5);
		
		txtDireccion = new JTextField();
		txtDireccion.setColumns(10);
		GridBagConstraints gbc_txtDireccion = new GridBagConstraints();
		gbc_txtDireccion.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtDireccion.insets = new Insets(0, 0, 5, 5);
		gbc_txtDireccion.gridx = 3;
		gbc_txtDireccion.gridy = 5;
		paneContacto.add(txtDireccion, gbc_txtDireccion);
		
		JLabel label_6 = new JLabel("Provincia");
		GridBagConstraints gbc_label_6 = new GridBagConstraints();
		gbc_label_6.anchor = GridBagConstraints.WEST;
		gbc_label_6.insets = new Insets(0, 0, 5, 5);
		gbc_label_6.gridx = 1;
		gbc_label_6.gridy = 7;
		paneContacto.add(label_6, gbc_label_6);
		
		txtProvincia = new JTextField();
		txtProvincia.setColumns(10);
		GridBagConstraints gbc_txtProvincia = new GridBagConstraints();
		gbc_txtProvincia.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtProvincia.insets = new Insets(0, 0, 5, 5);
		gbc_txtProvincia.gridx = 3;
		gbc_txtProvincia.gridy = 7;
		paneContacto.add(txtProvincia, gbc_txtProvincia);
		
		JLabel label_7 = new JLabel("C\u00F3digo postal");
		GridBagConstraints gbc_label_7 = new GridBagConstraints();
		gbc_label_7.anchor = GridBagConstraints.WEST;
		gbc_label_7.insets = new Insets(0, 0, 5, 5);
		gbc_label_7.gridx = 1;
		gbc_label_7.gridy = 9;
		paneContacto.add(label_7, gbc_label_7);
		
		txtCodPostal = new JTextField();
		txtCodPostal.setColumns(10);
		GridBagConstraints gbc_txtCodPostal = new GridBagConstraints();
		gbc_txtCodPostal.insets = new Insets(0, 0, 5, 5);
		gbc_txtCodPostal.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtCodPostal.gridx = 3;
		gbc_txtCodPostal.gridy = 9;
		paneContacto.add(txtCodPostal, gbc_txtCodPostal);
		
		JPanel panelCuenta = new JPanel();
		panelCuenta.setBorder(new TitledBorder(null, "Datos de la cuenta", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panelCuenta.setBackground(Color.WHITE);
		GridBagConstraints gbc_panelCuenta = new GridBagConstraints();
		gbc_panelCuenta.insets = new Insets(0, 0, 5, 5);
		gbc_panelCuenta.fill = GridBagConstraints.BOTH;
		gbc_panelCuenta.gridx = 1;
		gbc_panelCuenta.gridy = 5;
		add(panelCuenta, gbc_panelCuenta);
		GridBagLayout gbl_panelCuenta = new GridBagLayout();
		gbl_panelCuenta.columnWidths = new int[]{30, 0, 200, 0};
		gbl_panelCuenta.rowHeights = new int[]{15, 0, 10, 0, 10, 0, 0};
		gbl_panelCuenta.columnWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
		gbl_panelCuenta.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		panelCuenta.setLayout(gbl_panelCuenta);
		
		JLabel label_8 = new JLabel("Usuario");
		GridBagConstraints gbc_label_8 = new GridBagConstraints();
		gbc_label_8.anchor = GridBagConstraints.WEST;
		gbc_label_8.insets = new Insets(0, 0, 5, 5);
		gbc_label_8.gridx = 1;
		gbc_label_8.gridy = 1;
		panelCuenta.add(label_8, gbc_label_8);
		
		txtUsuario = new JTextField();
		txtUsuario.setColumns(10);
		GridBagConstraints gbc_txtUsuario = new GridBagConstraints();
		gbc_txtUsuario.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtUsuario.insets = new Insets(0, 0, 5, 0);
		gbc_txtUsuario.gridx = 2;
		gbc_txtUsuario.gridy = 1;
		panelCuenta.add(txtUsuario, gbc_txtUsuario);
		
		JLabel label_9 = new JLabel("Contrase\u00F1a");
		GridBagConstraints gbc_label_9 = new GridBagConstraints();
		gbc_label_9.anchor = GridBagConstraints.WEST;
		gbc_label_9.insets = new Insets(0, 0, 5, 5);
		gbc_label_9.gridx = 1;
		gbc_label_9.gridy = 3;
		panelCuenta.add(label_9, gbc_label_9);
		
		txtPass1 = new JPasswordField();
		txtPass1.setColumns(10);
		GridBagConstraints gbc_txtPass1 = new GridBagConstraints();
		gbc_txtPass1.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtPass1.insets = new Insets(0, 0, 5, 0);
		gbc_txtPass1.gridx = 2;
		gbc_txtPass1.gridy = 3;
		panelCuenta.add(txtPass1, gbc_txtPass1);
		
		JLabel label_10 = new JLabel("Repite tu contrase\u00F1a");
		GridBagConstraints gbc_label_10 = new GridBagConstraints();
		gbc_label_10.anchor = GridBagConstraints.EAST;
		gbc_label_10.insets = new Insets(0, 0, 0, 5);
		gbc_label_10.gridx = 1;
		gbc_label_10.gridy = 5;
		panelCuenta.add(label_10, gbc_label_10);
		
		txtPass2 = new JPasswordField();
		txtPass2.setColumns(10);
		GridBagConstraints gbc_txtPass2 = new GridBagConstraints();
		gbc_txtPass2.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtPass2.gridx = 2;
		gbc_txtPass2.gridy = 5;
		panelCuenta.add(txtPass2, gbc_txtPass2);
		
		JPanel panelBotones = new JPanel();
		panelBotones.setBackground(Color.WHITE);
		GridBagConstraints gbc_panelBotones = new GridBagConstraints();
		gbc_panelBotones.gridheight = 4;
		gbc_panelBotones.insets = new Insets(0, 0, 0, 5);
		gbc_panelBotones.fill = GridBagConstraints.BOTH;
		gbc_panelBotones.gridx = 1;
		gbc_panelBotones.gridy = 6;
		add(panelBotones, gbc_panelBotones);
		
		btnAceptar = new JButton("Aceptar");
		panelBotones.add(btnAceptar);
		
		 btnCancelar = new JButton("Cancelar");
		panelBotones.add(btnCancelar);

	}

	public String getTxtDNI() {
		return txtDNI.getText();
	}

	public String getTxtNombre() {
		return txtNombre.getText();
	}

	public String getTxtApellidos() {
		return txtApellidos.getText();
	}

	public String getTxtEmail() {
		return txtEmail.getText();
	}

	public String getTxtTelefono() {
		return txtTelefono.getText();
	}

	public String getTxtDireccion() {
		return txtDireccion.getText();
	}

	public String getTxtProvincia() {
		return txtProvincia.getText();
	}

	public String getTxtCodPostal() {
		return txtCodPostal.getText();
	}

	public String getTxtUsuario() {
		return txtUsuario.getText();
	}

	public char[] getTxtPass1() {
		return txtPass1.getPassword();
	}

	public char[] getTxtPass2() {
		return txtPass2.getPassword();
	}

	public JButton getBtnAceptar() {
		return btnAceptar;
	}

	public JButton getBtnCancelar() {
		return btnCancelar;
	}

	@Override
	public void update() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void SetVisible(boolean visible) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void registerListener(ActionListener listener) {
		this.btnAceptar.addActionListener(listener);
		this.btnCancelar.addActionListener(listener);
	}

}
